import java.util.ArrayList;
import java.util.Collections;


public class TestHelper3 {

	/**
	 * @param args
	 * @throws CloneNotSupportedException 
	 */
	
	
	
	public static void main(String[] args) throws CloneNotSupportedException {
		
		
		// create the board
		byte [][] t ={{Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL},
				{Board.WALL,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.WALL},
				{Board.WALL,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.WALL},
				{Board.WALL,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.WALL},
				{Board.WALL,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.EMPTY,Board.GOAL,Board.EMPTY,Board.WALL},
				{Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL,Board.WALL}};
		Board board = new Board(6, 8);
		for (int i=0; i<board.getNumRows();i++){
			for (int j=0;j<board.getNumColumns();j++){
				board.setData(i, j, t[i][j]);
			}
		}
		
		System.out.println(board.toString());
		
		
		// create the rank array

		//ArrayList<Position> g = Helper2.findGoals(board);
	
//	System.out.println("goal find : " + g.getI() +" " + g.getJ());
	
	
		int [][] rankArray = BoardRanker.distancesToAllTarget(board);
		for (int i = 0; i<board.getNumRows();i++){
			for (int j=0;j<board.getNumColumns();j++){
				System.out.print(rankArray[i][j] +" ");
			}
			System.out.println();
		}
		
		
	//Create the pnb
		
	Position playerPos = new Position(2,1);
	Position box1Pos = new Position (3,2);
	ArrayList<Position> boxesPos = new ArrayList<Position>();
	boxesPos.add(box1Pos);
		
	PlayerNBoxes pnb = new PlayerNBoxes(playerPos, boxesPos);

	// Create the list of possible moves
	ArrayList<Move> possibleMoves = Helper.possibleMoveBox(board, pnb);
	
	for(int i=0; i<possibleMoves.size();i++){
		System.out.println(possibleMoves.get(i).toString());
		PlayerNBoxes p = pnb.move(possibleMoves.get(i));
		p.setRank(rankArray);
		int ranki = p.getRank();
		System.out.println(ranki);
	}
	
	// rearange the list
	
//	ListCompare c = new ListCompare(rankArray, pnb, board );
//	
//	
//	Collections.sort(possibleMoves, c);
//	
	System.out.println();
	
	ArrayList<Move> a = new ArrayList<Move>();
	
	a = Helper.rankListOfMove(possibleMoves, rankArray, pnb, board);
	for(int i=0; i<a.size();i++){
		System.out.println(a.get(i).toString());
		PlayerNBoxes p = pnb.move(a.get(i));
		p.setRank(rankArray);
		int ranki = p.getRank();
		System.out.println(ranki);
	}		
	
	
		
	

	}

}
